package com.ruoyi.thread.service;

import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

import java.util.concurrent.CompletableFuture;

@Service
@Slf4j
public class ThreadO1Service {

    @Async
    public CompletableFuture<String> serviceOne(){
       log.info("serviceOne开始执行");
       try {
           Thread.sleep(3000);
       } catch (InterruptedException e) {
           e.printStackTrace();
       }
       log.info("serviceOne执行完毕");
       return CompletableFuture.completedFuture("serviceOne success");
    }


    @Async
    public CompletableFuture<String> serviceTwo(){
       log.info("serviceTwo开始执行");
       try {
           Thread.sleep(3000);
       } catch (InterruptedException e) {
           e.printStackTrace();
       }
       log.info("serviceTwo执行完毕");
       return CompletableFuture.completedFuture("serviceTwo success");
    }
}
